﻿Imports System.Drawing
Imports System.Reflection
Public Class Pn_Find
    Dim mStartColor As System.Drawing.Color
    Dim mEndColor As System.Drawing.Color
    Dim _GradientLeftToRight As Boolean
    Dim _StartColorPostion As Integer
    Dim _GradientLabelfont As Font
    Dim _GradientLabelforecolor As Color
    Dim _GradientLabelText As String
    Dim Centrepoint As Integer
    Dim _GradientAnchor As AnchorStyles
    Dim _FindText As String
    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
        Centrepoint = (Me.GroupBox1.Height - Me.Label1.Height) / 2
        Me.Label1.Top = Centrepoint
    End Sub
    Public Property FindText() As String
        Get
            Return _FindText
        End Get
        Set(ByVal value As String)
            _FindText = value
            Me.TextBox1.Text = value
        End Set
    End Property
    Public Property GradientColor1() As System.Drawing.Color
        Get
            Return mStartColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            mStartColor = value
            PaintGradient()
        End Set
    End Property
    Public Property GradientColor2() As System.Drawing.Color
        Get
            Return mEndColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            mEndColor = value
            PaintGradient()
        End Set
    End Property
    Public Property GradientLeftToRight() As Boolean
        Get
            Return _GradientLeftToRight
        End Get
        Set(ByVal value As Boolean)
            _GradientLeftToRight = value
            If _GradientLeftToRight = True Then
                _StartColorPostion = Me.GroupBox1.Width
            Else
                _StartColorPostion = Me.GroupBox1.Top
            End If
            PaintGradient()
        End Set
    End Property

    Public Property GradientFont() As Font
        Get
            Return _GradientLabelFont
        End Get
        Set(ByVal value As Font)
            _GradientLabelfont = value
            Change_GradientLabelFont()
        End Set
    End Property
    Public Property GradientForeColor() As Color
        Get
            Return _GradientLabelforecolor
        End Get
        Set(ByVal value As Color)
            _GradientLabelforecolor = value
            Change_GradientLabelForeColor()
        End Set
    End Property
    Public Property GradientHeaderText() As String
        Get
            Return _GradientLabelText
        End Get
        Set(ByVal value As String)
            _GradientLabelText = value
            Change_GrdientLabelText()
        End Set
    End Property
    'Public Property GradientStyle As 
    Sub PaintGradient()
        Try
            Dim gradBrush As New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(_StartColorPostion, Me.Height), GradientColor1, GradientColor2)
            Dim bmp As New Bitmap(GroupBox1.Width, GroupBox1.Height)
            Dim g As Graphics = Graphics.FromImage(bmp)
            g.FillRectangle(gradBrush, New Rectangle(0, 0, GroupBox1.Width, GroupBox1.Height))
            Me.GroupBox1.BackgroundImage = bmp
            GroupBox1.BackgroundImageLayout = ImageLayout.Stretch
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub
    Sub Change_GradientLabelFont()
        Me.Label1.Font = _GradientLabelfont

        Centrepoint = (Me.GroupBox1.Height - Me.Label1.Height) / 2
        Me.Label1.Top = Centrepoint

    End Sub
    Sub Change_GradientLabelForeColor()
        Me.Label1.ForeColor = _GradientLabelforecolor
    End Sub
    Sub Change_GrdientLabelText()
        Me.Label1.Text = _GradientLabelText
    End Sub

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        mStartColor = Color.CornflowerBlue
        mEndColor = Color.MidnightBlue

        _GradientLeftToRight = False
        _GradientLabelfont = Me.Label1.Font
        _GradientLabelforecolor = Me.Label1.ForeColor
        _GradientLabelText = "Title"
        PaintGradient()
        ' Add any initialization after the InitializeComponent() call.

    End Sub
    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)
    End Sub
    Protected Overloads Overrides Sub OnDragDrop(ByVal drgevent As System.Windows.Forms.DragEventArgs)
        MyBase.OnDragDrop(drgevent)
    End Sub
    Protected Overloads Overrides Sub OnDragEnter(ByVal drgevent As System.Windows.Forms.DragEventArgs)
        MyBase.OnDragEnter(drgevent)
    End Sub

    Private Sub FindText_KeyEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        '    If e.KeyCode = Keys.Enter Then
        '        TEXT = TextBox1.Text
        '    End If
    End Sub


End Class
